package com.bsoft.controller;

import com.bsoft.pojo.User;
import com.bsoft.repository.UserRepository02;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class MongodbController2 {
    @Autowired
    private UserRepository02 userRepository02;

    @GetMapping("/testFindName")
    public void testFindByName() {
        User byUsername = userRepository02.findByUsername(" hdh");
        System.out.println(byUsername);
    }

//    public Object testFindByNameLike(){
//        //创建排序条件
//        Sort sort = new Sort(Sort.Direction.DESC, "id"); // ID 倒序
//        //创建分页条件
//        PageRequest pageRequest = PageRequest.of(0, 10, sort);
//        //执行分页操作
//        Page<User> h = userRepository02.findByUsernameLike("h", pageRequest);
//        System.out.println(h.getTotalElements());
//        System.out.println(h.getTotalPages());
//
//        return h;
//    }
}
